﻿
namespace ap2.Phone.Core.Data
{
    using System;
    using System.Collections.Generic;
    
    public interface ISession : IDisposable
    {
        /// <summary>
        /// Commits changes to disk
        /// </summary>
        void CommitChanges();
        /// <summary>
        /// Deletes subset of objects
        /// </summary>
        void Delete<T>(Func<T, bool> expression);
        /// <summary>
        /// Deletes an item from the database
        /// </summary>
        /// <param name="item"></param>
        void Delete<T>(T item);
        /// <summary>
        /// Deletes all T objects
        /// </summary>
        void DeleteAll<T>();
        /// <summary>
        /// Finds an item using a passed-in expression lambda
        /// </summary>
        T Single<T>(Func<T, bool> expression);
        /// <summary>
        /// Returns all T records in the repository
        /// </summary>
        IEnumerable<T> All<T>();
        /// <summary>
        /// Saves an item to the database
        /// </summary>
        /// <param name="item"></param>
        void Save<T>(T item);

        void Dispose();
    }
}
